
public class Transformations {
	public static void octaveDisp(Integer[] pitches, int chord)
	{

	}
	@SuppressWarnings("null")
	public static int[] makeScale(int key, int scaleType)
	{
		int[] scale=null;
		for (int i=0;i<Constants.scales[scaleType].length;i++)
		{
			scale[i]=(Constants.scales[scaleType][i]+key)%12;
		}
		return scale;
	}
	public static int[] makeScaleMajorMinor(int key, boolean keyMajor)
	{
		int[] scale=new int[Constants.scales[Constants.ionian].length];
		if (keyMajor)
			for (int i=0;i<Constants.scales[Constants.ionian].length;i++)
			{
				scale[i]=(Constants.scales[Constants.ionian][i]+key)%12;
			}
		else
		{
			for (int i=0;i<Constants.scales[Constants.aeolian].length;i++)
			{
				scale[i]=(Constants.scales[Constants.aeolian][i]+key)%12;
			}
		}
		return scale;
	}
	public static boolean noteInScale(int pitch, int[] scale) // is a certain note in the current key / scale
	{
		boolean inScale = false;
		for (int i=0;i<scale.length;i++)
		{
			if (pitch%12==scale[i])
			{
				inScale=true;
			}
		}
		
		return inScale;
	}
	
	public static boolean noteInScaleIndex(int pitch, int[] scale) // is a certain note in the current key / scale
	{
		boolean inScale = false;
		@SuppressWarnings("unused")
		int index=0;
		for (int i=0;i<scale.length;i++)
		{
			if (pitch%12==scale[i])
			{
				inScale=true;
				index=i;
			}
			if (!inScale&&scale[i]==pitch%12+1)
			{
				
			}
		}
		
		return inScale;
	}
	
	public static int[][] passingTones(int[][] notes)
	{
		for (int i=1;i<notes[0].length;i++) // iterate through all of the notes in the chunk
		{
			if (Math.random()<Main.stats.passingTonesArray[(notes[0][i]-Main.score.key)%12]) // odds that a given pitch class (relative to the chord) is preceded by a passing tone
//			if (true)
			{
				if ((Math.abs(notes[0][i]-notes[0][i-1]))>1) // if interval between notes is larger than a half step
				{
					int pitch = 0;
					if ((Math.abs(notes[0][i]-notes[0][i-1]))>2) // if interval between notes is larger than a full step
					{
						if (notes[0][i]-notes[0][i-1]>1)	// is the interval increasing?
						{
							if (noteInScale(notes[0][i]-1,makeScaleMajorMinor(Main.score.key,!Main.score.isMinor))&&Math.random()>Main.stats.passingTonesChromatic) // is pitch-1 diatonic AND choose b/w diatonic or chromatic PT
							{
								pitch = notes[0][i]-1; // make the PT the pitch between the full step									
							}
							else
							{
								pitch = notes[0][i]-2; // choose diatonic note that is two half steps away 
							}
						}
						else
						{
							if (noteInScale(notes[0][i]+1,makeScaleMajorMinor(Main.score.key,!Main.score.isMinor))&&Math.random()>Main.stats.passingTonesChromatic) // is pitch+1 diatonic AND choose b/w diatonic or chromatic PT
							{
								pitch = notes[0][i]+1; // make the PT the pitch between the full step									
							}
							else
							{
								pitch = notes[0][i]+2; // choose diatonic note that is two half steps away 
							}								
						}
					}
					else // there is a full step between the notes
					{
						if (notes[0][i]-notes[0][i-1]>1)	// is the interval increasing?
						{
							pitch = notes[0][i]-1; // make the PT the pitch between the full step
						}
						else
						{
							pitch = notes[0][i]+1; // make the PT the pitch between the full step								
						}
					}
					int[][] tempMatrix = new int[2][notes[0].length+1];
					for (int j=0;j<=notes[0].length;j++)
					{
						if (j<=i-1)
						{
							tempMatrix[0][j]=notes[0][j];
							tempMatrix[1][j]=notes[1][j];
						}
						else if(j==i)
						{
							System.out.println("pitch = "+notes[0][j]);
							System.out.println("duration = "+notes[1][j]);
							tempMatrix[0][j]=pitch;
							tempMatrix[1][j]=(notes[1][j]-notes[1][j-1])/2+notes[1][j-1];
						}
						else if(j>i)
						{
							tempMatrix[0][j]=notes[0][j-1];
							tempMatrix[1][j]=notes[1][j-1];
						}
						else
						{
							tempMatrix[0][j]=notes[0][j-1];
							tempMatrix[1][j]=notes[1][j-1];
						}
					}
					notes=tempMatrix;
					i++;
				}
			}
		}
		
	return notes;
	}
}
